<?php

require_once 'Video.php'; // import('Video');
import('VideoPlayer.~');

class PlayersVideos extends Video {

	/**
	 * FormContact::__construct()
	 *
	 */
	public function __construct ( ) {
	}

	public function showAllVideos(){
		$video = new Video();
		$arrayVideos = $video->showAll();
		# Création du html des players
		try {
			$videos = '';
			foreach($arrayVideos as $key => $val){
				$param = array(
					'server' => array(
					    'server' => $arrayVideos[$key]['serveur'],
					    'id' => $arrayVideos[$key]['id_serveur']
					),
					'player' => array(
					    'width' => 800,
					    'height' => 500
					)
				);
				$videos .= self::player($param);
			}
			return $videos;
		} catch ( Hoa_Exception $e ) {
			$e->raiseError();
		}

	}

	private function player(array $param) {
		$player = new Hoa_VideoPlayer($param);
		return '<div class="video">'.$player->__tostring().'</div>';

		if (DEBUG) {
			echo '<br />';
			echo '<br />Nom du serveur: '.$player->getServerName();
			echo '<br />Id de la video: '.$player->getVideoId();
			echo '<br />URL de la video: <a href="'.$player->getVideoUrl().'" target="_blank">'.$player->getVideoUrl().'</a>';
			echo '<br />Parametre du player: <pre>'.print_r($player->getPlayerParam(), true).'</pre>';
			echo '<br />Parametre du server: <pre>'.print_r($player->getServerParam(), true).'</pre>';
			echo '<br />Code HTML: <pre style="background:#EFEFEF;">'.htmlentities($player).'</pre>';
			echo '<hr />';
		}
	}

}